package com.kczd.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.kczd.activity.OrderOverDetailActivity;
import com.kczd.adapter.LocationAdapter;
import com.kczd.client.R;
import com.kczd.entity.Location;

import java.util.ArrayList;
import java.util.List;

/**
 * zhangy
 * Created by Administrator on 2017/3/5 0005.
 */

public class OrderOverFragment extends Fragment{
    private View view;
    private ListView lv_accomplish;
    public static List<Location> orderOverlsit = new ArrayList<Location>();
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.fragment_order_over, null);

        setview();
        return view;
    }
    private void setview() {
        //将数据显示在listview上
        //1.获得ListView对象
        lv_accomplish=(ListView) view.findViewById(R.id.lv_accomplish);
        //2.构建Adapter对象
        LocationAdapter adapter=new LocationAdapter(getActivity(), R.layout.list_item_order_item, orderOverlsit);
        lv_accomplish.setAdapter(adapter);
        lv_accomplish.setOnItemClickListener(new AdapterView.OnItemClickListener(){

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {
                //新建一个显式意图，第一个参数为当前Activity类对象，第二个参数为你要打开的Activity类
                Intent intent =new Intent(getActivity(), OrderOverDetailActivity.class);

                //用Bundle携带数据
                Bundle bundle=new Bundle();
                //传递参数
                bundle.putInt("position", position);
                intent.putExtras(bundle);

                startActivity(intent);
            }

        });
    }
}
